Source Code Viewer - Example 4 - Form

package name.matthewgreet.example4.common;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * <P>Defines a member variable of a Struts action as receiving an injected form processed by another Struts action, 
 * whether successfully or not, usually to display it.  The member variable is only set if the form's type is compatible 
 * with its type.</P>
 * 
 * <P>If any <CODE>processors</CODE> are set, the class of the Struts action that processed the form (successfully or 
 * not) must match or be a subclass one of the values.  This is useful if multiple displayed forms happen to be the same
 * type.</P>
 * 
 * <P>By default, the member variable is only set if the form's processor rejected the form.  How <CODE>reception</CODE> 
 * values affect form data reception:</P>
 * <DL>
 * <DT>NEVER</DT><DD>Nevers accepts form data.</DD>
 * <DT>ERROR</DT><DD>Only if form data was rejected.  Default.</DD>
 * <DT>SUCCESS</DT><DD>Only if form data was accepted.</DD>
 * <DT>ALWAYS</DT><DD>Always accepts form data.</DD>
 * </DL>
 */
@Documented
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Form {
    public enum Reception {NEVER, ERROR, SUCCESS, ALWAYS}
    
    public Class<?>[] processors() default {};
    public Reception reception() default Reception.ERROR;
}